
#include "sample_vin.h"
#include "sample_isp.h"
#include "sample_vout.h"
#include "sample_venc.h"

extern int g_save_h264_file_flag;

int main(int argc, char *argv[])
{

    int ret = SGKS_SUCCESS;
    int enc_test_mode = 0;
    int i = 0;
    struct inparam inputparam;

	printf("**********************************************************************\n");
	printf("* sgks mpi sample enc svn version: %s  build time: %s  \r\n",SVNREVISION,TIMESTAMP);
	printf("**********************************************************************\n");

    memset(&inputparam, 0x00, sizeof(inputparam));
    inputparam.argc = argc;
    for(i = 0; i < inputparam.argc; i++)
    {
        strcpy((char*)&inputparam.argv[i][0], (const char*)argv[i]);
    }

    if(strcmp((const char*)&inputparam.argv[1][0], "1") == 0)
    {
        enc_test_mode = SENSOR_DATA_ENCODE_TEST;
        if(strcmp((char*)&inputparam.argv[2][0], "1") == 0)
        {
            g_save_h264_file_flag = 1;
        }
    }
    else if(strcmp((const char*)&inputparam.argv[1][0], "2") == 0)
    {
        if(strcmp((const char*)&inputparam.argv[2][0], "1") == 0)
        {
            enc_test_mode = YUV_DATA_H264_ENCODE_TEST;
        }
        else if(strcmp((char*)&inputparam.argv[2][0], "2") == 0)
        {
            enc_test_mode = YUV_DATA_MJPEG_ENCODE_TEST;
        }
        g_save_h264_file_flag = 1;
    }
    else if(strcmp((const char*)&inputparam.argv[1][0], "3") == 0)
    {
        enc_test_mode = START_STOP_PRESSURE_TEST;
        if(strcmp((const char*)&inputparam.argv[2][0], "1") == 0)
        {
            g_save_h264_file_flag = 1;
        }
    }

    if(enc_test_mode == 0)
    {
        DEBUGMSG(ZONE_ERROR, ("Please input test params:\n"));
        DEBUGMSG(ZONE_ERROR, ("./sample-venc 1   --> sensor data to encode(do not save file)\n"));
        DEBUGMSG(ZONE_ERROR, ("./sample-venc 1 1 --> sensor data to encode(save file)\n"));

        DEBUGMSG(ZONE_ERROR, ("./sample-venc 2  1  --> yuv data to h264 encode\n"));
        DEBUGMSG(ZONE_ERROR, ("./sample-venc 2  2  --> yuv data to MJPEG encode\n"));

        DEBUGMSG(ZONE_ERROR, ("./sample-venc 3   --> encode pressure test(do not save file)\n"));
        DEBUGMSG(ZONE_ERROR, ("./sample-venc 3  1--> encode pressure test(save file)\n"));

        return SGKS_SUCCESS;
    }

    ret = sgks_mpi_sample_SysInit(SGKS_DSP_ENCODE_MODE);
    if (ret != SGKS_SUCCESS)
        return ret;

    ret = sgks_mpi_sample_VinInit();
    if (ret != SGKS_SUCCESS)
        return ret;

    ret = sgks_mpi_sample_IspInit();
    if (ret != SGKS_SUCCESS)
        return ret;

    ret = sgks_mpi_sample_VoutInit(SGKS_VO_SRC_ENC, SGKS_VO_SRC_ENC);
    if (ret != SGKS_SUCCESS)
        return ret;

    ret =  sgks_mpi_sample_venc_setting(enc_test_mode);
    if (ret != SGKS_SUCCESS)
        return ret;

    ret =  sgks_mpi_sys_Start();
    if (ret != SGKS_SUCCESS)
        return ret;

    ret = sgks_mpi_sample_venc_start();
    if (ret != SGKS_SUCCESS)
        return ret;

    ret = sgks_mpi_sample_venc_test(enc_test_mode);
    if (ret != SGKS_SUCCESS)
        return ret;

    while(1)
    {
        sleep(1);
    }

    return SGKS_SUCCESS;


}




